<?php
declare (strict_types=1);

namespace app\controller\admin;

use app\common\controller\BaseController;
use app\model\admin\Config as configModel;
use think\App;
use \Throwable;

class Config extends BaseController
{
    protected $model;

    public function __construct(App $app, configModel $model)
    {
        parent::__construct($app);
        $this->model = $model;
    }

    /**
     * @return mixed
     * 详情
     */
    public function detail()
    {
        try {
            validate(\app\validate\admin\Config::class)->scene('detail')->check($this->params);
        } catch (\Exception $ex) {
            return $this->returnException($ex);
        }
        return $this->model->getOne($this->params);
    }

    /**
     * 编辑
     * PUT    blog/:id
     * @return array
     */
    public function update()
    {
        try {
            return $this->model->edit($this->params);
        } catch (Throwable $ex) {
            return $this->returnException($ex);
        }
    }
}
